package com.jeomo.mem.provider.web;

import com.jeomo.common.core.result.CommonResult;
import com.jeomo.common.core.util.BeanCopyUtil;
import com.jeomo.mem.provider.vo.PointsClearVo;
import com.jeomo.mem.starter.sysoption.PointsClearSysOption;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 积分清零配置
 */
@RestController
@RequestMapping("points")
public class PointsClearController {

    @Resource
    private PointsClearSysOption pointsClearSysOption;

    @PostMapping("clear")
    public CommonResult saveOption(@RequestBody PointsClearVo pointsClearVo){

        BeanCopyUtil.copyProperties(pointsClearVo,pointsClearSysOption);
        boolean save = pointsClearSysOption.save();
        return save?CommonResult.success("保存成功"):CommonResult.failure("保存失败");
    }

    @GetMapping("clear")
    public CommonResult<PointsClearVo> getOption(){

        pointsClearSysOption.load();
        PointsClearVo pointsClearVo = BeanCopyUtil.copyProperties(pointsClearSysOption, PointsClearVo.class);
        return CommonResult.success(pointsClearVo);
    }

}
